//
//  HHTagListConfig.m
//  ZHTagList
//
//  Created by Basic on 2018/10/20.
//

#import "HHTagListConfig.h"
#import <BCFoundation/UIColor+BCHelper.h>


@implementation HHTagListConfig
- (instancetype)init
{
    self = [super init];
    if (self) {
        _rowSpacing = 15;
        _lineSpacing = 9;
        _maxLine = 3;
        _itemImgTextSpace = -1;//未设置
        //        _padding = UIEdgeInsetsMake(5, 15, 5, 15);
        _maxLayoutWidth = [UIScreen mainScreen].bounds.size.width;
        _itemCornerRadius = 15.0;
        _itemTextColor = [UIColor blackColor];
        _itemBgColor = [UIColor whiteColor];
        _itemSelectTextColor = [UIColor whiteColor];
        _itemSelectBgColor = kBCRGBColor(0x3FD3AC);
        _itemFont = [UIFont systemFontOfSize:15];
        _itemPadding = UIEdgeInsetsMake(5, 10, 5, 10);
    }
    return self;
}

//MARK: - setter
-(void)setMaxLayoutWidth:(CGFloat)maxLayoutWidth {
    _maxLayoutWidth = maxLayoutWidth;
    if (maxLayoutWidth>0 &&_fixedColumnCount>0) {
        //如果这里是固定宽度，计算固定宽度
        _fixedItemWidth = (_maxLayoutWidth - _contentPadding.left - _contentPadding.right - _linePadding.left - _linePadding.right - (_fixedColumnCount-1)*_rowSpacing)*1.0/_fixedColumnCount;
    }
}
-(void)setFixedColumnCount:(NSInteger)fixedColumnCount {
    _fixedColumnCount = fixedColumnCount;
    if (_maxLayoutWidth>0 && fixedColumnCount>0) {
        //如果这里是固定宽度，计算固定宽度
        _fixedItemWidth = (_maxLayoutWidth - _contentPadding.left - _contentPadding.right - _linePadding.left - _linePadding.right - (_fixedColumnCount-1)*_rowSpacing)*1.0/_fixedColumnCount;
    }
}

//MARK: - getter
-(CGFloat)itemImgTextSpace {
    //判断是否设置了间距
    if (_itemImgTextSpace>-1) {
        //如果设置了间距，直接返回
        return _itemImgTextSpace;
    }
    //其次，有图片，默认间距 15
    if (_itemImg) {
        return 15;
    }
    return 0;
}
@end
